﻿using nRoute.Navigation.Mapping;
using nRoute.Samples.Netflix.Data.Catalog;
using nRoute.Samples.Netflix.Views;
using nRoute.ViewModels;
using nRoute.Navigation;

namespace nRoute.Samples.Netflix.ViewModels
{
    [DefineNavigationContent("Content/Netflix/BoxArt/", typeof(BoxArtView))]
    [MapViewModel(typeof(BoxArtView))]
    public class BoxArtViewModel
        : NavigationViewModelBase
    {
        private const string BOXART_KEY = "BoxArt";

        public string BoxArtUrl { get; private set; }

        protected override void OnIntialize(Components.ParametersCollection state)
        {
            var _boxArt = (BoxArt)state[BOXART_KEY];
            this.BoxArtUrl = _boxArt.HighDefinitionUrl ?? _boxArt.LargeUrl ?? _boxArt.MediumUrl;
            NotifyPropertyChanged(() => BoxArtUrl);
        }
    }
}
